home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Cursor;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.event.MouseMotionListener;
- import java.awt.image.MemoryImageSource;
- import java.awt.image.PixelGrabber;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLEncoder;
-
- public class ImageConvex2 extends Applet implements Runnable, MouseListener, MouseMotionListener {
- boolean loaded;
- Thread thread;
- Image image;
- Image buffer;
- // $FF: renamed from: b java.awt.Graphics
- Graphics field_0;
- Color backColor;
- // $FF: renamed from: wi int
- int field_1;
- // $FF: renamed from: he int
- int field_2;
- int wiIm;
- int heIm;
- int pause = 20;
- static int[] pix;
- static int[] pixnew;
- int radius;
- // $FF: renamed from: X int
- int field_3;
- // $FF: renamed from: Y int
- int field_4;
- float IConv = 1.0F;
- float IConvIni;
- int dimMin;
- private String statusBarText;
- private AudioClip sound;
- private AudioClip clicSound;
- private AudioClip enterSound;
- private boolean loopSound;
- private String link;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_5;
- private String enterText;
- private boolean isEnterTextEnabled;
- private int wiEnterText;
- private int enterTextHeight;
- private Color enterTextColor;
- private int decx;
- private int decy;
-
- public String getAppletInfo() {
- return "Name: ImageConvex2\r\nAuthor: Taiji Software\r\n";
- }
-
- public ImageConvex2() {
- this.backColor = Color.black;
- this.IConvIni = 4.0F;
- this.radius = 30;
- ((Component)this).addMouseListener(this);
- ((Component)this).addMouseMotionListener(this);
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- this.stop();
- } catch (Exception e) {
- System.out.println(e);
- this.stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var11) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- this.image = ((Applet)this).getImage(((Applet)this).getCodeBase(), ((Applet)this).getParameter("image_name"));
- MediaTracker tracker = new MediaTracker(this);
- tracker.addImage(this.image, 0);
-
- try {
- tracker.waitForAll();
- tracker.isErrorAny();
- } catch (Exception e) {
- System.err.println(e);
- }
-
- if (!this.loaded) {
- this.stop();
- }
-
- this.wiIm = this.image.getWidth(this);
- this.heIm = this.image.getHeight(this);
- this.decx = (this.field_1 - this.wiIm) / 2;
- this.decy = (this.field_2 - this.heIm) / 2;
- pix = new int[this.wiIm * this.heIm];
- pixnew = new int[this.wiIm * this.heIm];
- PixelGrabber pixg = new PixelGrabber(this.image, 0, 0, this.wiIm, this.heIm, pix, 0, this.wiIm);
-
- try {
- pixg.grabPixels();
- } catch (InterruptedException var9) {
- }
-
- this.image = ((Component)this).createImage(new MemoryImageSource(this.wiIm, this.heIm, pixnew, 0, this.wiIm));
- this.buffer = ((Component)this).createImage(this.field_1, this.field_2);
- this.field_0 = this.buffer.getGraphics();
- this.field_0.setColor(this.enterTextColor);
- String fontName = ((Applet)this).getParameter("enter_text_font");
- if (fontName == null) {
- fontName = "TimesRoman";
- }
-
- int style = 1;
- String s = ((Applet)this).getParameter("enter_text_style");
- if (s != null) {
- if (s.equals("bold")) {
- style = 1;
- } else if (s.equals("italic")) {
- style = 2;
- } else if (s.equals("bold_italic")) {
- style = 3;
- } else {
- style = 0;
- }
- }
-
- this.field_0.setFont(new Font(fontName, style, this.enterTextHeight));
- this.field_5 = this.field_0.getFontMetrics();
- if (this.enterText != null) {
- this.wiEnterText = this.field_5.stringWidth(this.enterText);
- }
-
- this.field_3 = (int)((float)this.wiIm / 2.0F);
- this.field_4 = (int)((float)this.heIm / 2.0F);
- if (this.wiIm >= this.heIm) {
- this.dimMin = this.heIm;
- } else {
- this.dimMin = this.wiIm;
- }
-
- if (this.sound != null) {
- if (this.loopSound) {
- this.sound.loop();
- return;
- }
-
- this.sound.play();
- }
-
- }
-
- public void getParameters() {
- this.field_1 = ((Component)this).getSize().width;
- this.field_2 = ((Component)this).getSize().height;
- String s = ((Applet)this).getParameter("pause");
- if (s != null) {
- this.pause = Integer.parseInt(s);
- }
-
- this.backColor = this.getColor("background_color");
- ((Component)this).setBackground(this.backColor);
- s = ((Applet)this).getParameter("radius");
- if (s != null) {
- this.radius = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("convexity");
- if (s != null) {
- this.IConvIni = (float)((double)((float)Integer.parseInt(s)) / (double)10.0F);
- }
-
- this.statusBarText = ((Applet)this).getParameter("status_bar_text");
- s = ((Applet)this).getParameter("sound_name");
- if (s != null) {
- this.sound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- s = ((Applet)this).getParameter("loop_sound");
- if (s != null) {
- if (s.equals("yes")) {
- this.loopSound = true;
- } else {
- this.loopSound = false;
- }
- }
-
- s = ((Applet)this).getParameter("clic_sound_name");
- if (s != null) {
- this.clicSound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- s = ((Applet)this).getParameter("enter_sound_name");
- if (s != null) {
- this.enterSound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- this.link = ((Applet)this).getParameter("link");
- this.enterText = ((Applet)this).getParameter("enter_text");
- s = ((Applet)this).getParameter("enter_text_height");
- if (s != null) {
- this.enterTextHeight = Integer.parseInt(s);
- }
-
- this.enterTextColor = this.getColor("enter_text_color");
- if (this.enterTextColor == null) {
- this.enterTextColor = Color.white;
- }
-
- }
-
- public Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public void start() {
- if (this.thread == null) {
- this.thread = new Thread(this);
- this.thread.start();
- }
-
- }
-
- public void stop() {
- if (this.thread != null) {
- this.thread = null;
- }
-
- if (this.sound != null) {
- this.sound.stop();
- }
-
- }
-
- public void run() {
- Thread.currentThread().setPriority(4);
-
- while(true) {
- ((Component)this).repaint();
-
- try {
- Thread.sleep((long)this.pause);
- } catch (InterruptedException var1) {
- }
-
- this.calculatePixels();
- }
- }
-
- public final void paint(Graphics g) {
- if (!this.loaded) {
- this.field_0.setColor(Color.white);
- this.field_0.drawString("loading... please wait", 1, this.field_2 / 2);
- this.loaded = true;
- } else {
- if (this.image != null) {
- this.field_0.clearRect(0, 0, this.field_1, this.field_2);
- this.field_0.drawImage(this.image, this.decx, this.decy, this);
- if (this.isEnterTextEnabled) {
- this.field_0.drawString(this.enterText, (this.field_1 - this.wiEnterText) / 2, this.field_2 / 2);
- }
-
- this.image = null;
- }
-
- g.drawImage(this.buffer, 0, 0, this);
- }
- }
-
- public final void update(Graphics g) {
- this.paint(g);
- }
-
- private final void calculatePixels() {
- for(int ii = 0; ii < this.heIm; ++ii) {
- for(int jj = 0; jj < this.wiIm; ++jj) {
- int i = jj - this.field_3 + this.decx;
- int j = ii - this.field_4 + this.decy;
- float r1 = (float)Math.sqrt((double)(i * i + j * j));
- float r2 = 1.0F;
- if (r1 < (float)this.radius) {
- r2 = this.IConv - (this.IConv - 1.0F) * r1 / (float)this.radius;
- }
-
- float r3 = (float)i / r2 + (float)(this.field_3 - this.decx);
- float r4 = (float)j / r2 + (float)(this.field_4 - this.decy);
- if (r1 < (float)this.radius) {
- if (r3 > 0.0F && r3 < (float)(this.wiIm - 1) && r4 > 0.0F && r4 < (float)(this.heIm - 1)) {
- float r5 = r3 - (float)((int)r3);
- float r6 = r4 - (float)((int)r4);
- int a = (int)((1.0F - r5) * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3, 16711680, 16) + (1.0F - r5) * r6 * (float)this.pixel((int)r4 + 1, (int)r3, 16711680, 16) + r5 * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3 + 1, 16711680, 16) + r5 * r6 * (float)this.pixel((int)r4 + 1, (int)r3 + 1, 16711680, 16));
- int b = (int)((1.0F - r5) * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3, 65280, 8) + (1.0F - r5) * r6 * (float)this.pixel((int)r4 + 1, (int)r3, 65280, 8) + r5 * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3 + 1, 65280, 8) + r5 * r6 * (float)this.pixel((int)r4 + 1, (int)r3 + 1, 65280, 8));
- int c = (int)((1.0F - r5) * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3, 255, 0) + (1.0F - r5) * r6 * (float)this.pixel((int)r4 + 1, (int)r3, 255, 0) + r5 * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3 + 1, 255, 0) + r5 * r6 * (float)this.pixel((int)r4 + 1, (int)r3 + 1, 255, 0));
- pixnew[ii * this.wiIm + jj] = (new Color(a, b, c)).getRGB();
- } else {
- pixnew[ii * this.wiIm + jj] = this.backColor.getRGB();
- }
- } else {
- pixnew[ii * this.wiIm + jj] = pix[ii * this.wiIm + jj];
- }
- }
- }
-
- this.image = ((Component)this).createImage(new MemoryImageSource(this.wiIm, this.heIm, pixnew, 0, this.wiIm));
- }
-
- public final int pixel(int i, int j, int hex, int dec) {
- return (pix[i * this.wiIm + j] & hex) >> dec;
- }
-
- public URL giveURL(String url) {
- try {
- if (url.toUpperCase().startsWith("HTTP")) {
- return new URL(url);
- } else if (url.toUpperCase().startsWith("FTP")) {
- int p = url.indexOf(":");
- int p2 = url.indexOf(":", p + 1);
- if (p2 != -1) {
- url = url.substring(0, p + 3) + URLEncoder.encode(url.substring(p + 3, url.length()));
- }
-
- p = url.indexOf("%40");
- if (p != -1) {
- url = url.substring(0, p) + "@" + url.substring(p + 3, url.length());
- }
-
- return new URL(url);
- } else {
- return new URL(((Applet)this).getCodeBase(), url);
- }
- } catch (MalformedURLException e) {
- System.out.println(e);
- return null;
- }
- }
-
- public void mouseClicked(MouseEvent e) {
- }
-
- public void mouseEntered(MouseEvent e) {
- this.IConv = this.IConvIni;
- if (this.enterText != null) {
- this.isEnterTextEnabled = true;
- this.field_0.setColor(this.enterTextColor);
- ((Component)this).repaint();
- }
-
- if (this.statusBarText != null) {
- ((Applet)this).showStatus(this.statusBarText);
- }
-
- if (this.enterSound != null) {
- this.enterSound.play();
- }
-
- if (this.link != null) {
- ((Component)this).setCursor(new Cursor(12));
- }
-
- }
-
- public void mouseExited(MouseEvent e) {
- this.IConv = 1.0F;
- if (this.isEnterTextEnabled) {
- this.isEnterTextEnabled = false;
- ((Component)this).repaint();
- }
-
- if (this.link != null) {
- ((Component)this).setCursor(new Cursor(0));
- }
-
- }
-
- public void mousePressed(MouseEvent e) {
- if (this.clicSound != null) {
- this.clicSound.play();
- }
-
- if (this.link != null) {
- String target = ((Applet)this).getParameter("target");
- if (target == null) {
- target = "_blank";
- }
-
- URL u = this.giveURL(this.link);
- ((Applet)this).getAppletContext().showDocument(u, target);
- }
-
- }
-
- public void mouseReleased(MouseEvent e) {
- }
-
- public void mouseDragged(MouseEvent e) {
- }
-
- public void mouseMoved(MouseEvent e) {
- this.field_3 = e.getX();
- this.field_4 = e.getY();
- }
- }
-